package com.sgb.kjwl.view.ui.adapter.transport;

import android.graphics.Color;
import android.text.TextUtils;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.GoodsManageItemData;
import com.sgb.kjwl.model.entity.transport.AttachmentListEntity;
import com.sgb.kjwl.model.entity.transport.SingleItemConstant;
import com.sgb.kjwl.utils.CargoConstant;
import com.sgb.kjwl.utils.DefaultUtil;
import com.sgb.kjwl.utils.NumberUtil;

import java.util.List;

/**
 * @author: 熊丽
 * @date: 2021/10/11 15:32
 * @Description: 搜索车队列表适配器
 */
public class InvitationFleetItemAdapter extends BaseQuickAdapter<AttachmentListEntity, BaseViewHolder> {
    public InvitationFleetItemAdapter(@Nullable List<AttachmentListEntity> data) {
        super(R.layout.item_invitation_fleet, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AttachmentListEntity item) {
        helper.setText(R.id.tv_item_invitation_name, item.getName());
        helper.setText(R.id.tv_item_operate_type_name, TextUtils.isEmpty(item.getBusinessType())?"/":item.getBusinessType());
        helper.setText(R.id.tv_item_business_name,TextUtils.isEmpty(item.getMainBusiness())?"/": item.getMainBusiness());
        if (item.getIsAdd()==1&&item.getLinkState()!=null){
            if (item.getLinkState()==1){
                helper.setVisible(R.id.v_item_cm_cover,true);
                helper.setVisible(R.id.tv_item_invitation_tips,true);
                helper.setText(R.id.tv_item_invitation_tips,"已邀请，待车队同意");
                helper.setTextColor(R.id.tv_item_invitation_tips, Color.parseColor("#FFC000"));
            }else if (item.getLinkState()==3){
                helper.setVisible(R.id.v_item_cm_cover,true);
                helper.setVisible(R.id.tv_item_invitation_tips,true);
                helper.setText(R.id.tv_item_invitation_tips,"已邀请，车队已同意");
                helper.setTextColor(R.id.tv_item_invitation_tips, Color.parseColor("#06C764"));
            }else {
                helper.setVisible(R.id.tv_item_invitation_tips,false);
                helper.setVisible(R.id.v_item_cm_cover,false);
                helper.addOnClickListener(R.id.tv_item_invitation_edit);
            }
        }else {
            helper.setVisible(R.id.tv_item_invitation_tips,false);
            helper.setVisible(R.id.v_item_cm_cover,false);
            helper.addOnClickListener(R.id.tv_item_invitation_edit);
        }
        helper.addOnClickListener(R.id.cl_fleet_item);
    }
}
